﻿using System.Configuration;
using Ninject;
using Ninject.Modules;
using SeaBattle.Domain.Abstract;
using SeaBattle.Domain.Abstract.Services;
using SeaBattle.Domain.Concrete;
using SeaBattle.Domain.Concrete.Services;

namespace SeaBattle.Domain.Factory
{
    public class PlayerFactory
    {
        private static readonly IKernel Kernel = new StandardKernel(new PlayerFactoryServices());

        public static IPlayerRepository PlayerRepository
        {
            get { return (IPlayerRepository)Kernel.Get(typeof(IPlayerRepository)); }
        }

        public static IPlayerService PlayerService
        {
            get { return (IPlayerService)Kernel.Get(typeof(IPlayerService)); }
        }

        private class PlayerFactoryServices : NinjectModule
        {
            public override void Load()
            {
                Bind<IPlayerRepository>().To<SqlPlayerRepository>().WithConstructorArgument(
                   "connectionString", ConfigurationManager.ConnectionStrings["ApplicationServicesLocal"].ConnectionString);
                Bind<IPlayerService>().To<PlayerService>();
            }
        }


    }
}
